<template>
	<view class="dynamicModel-list-v">
		<view class="company-message">
			<u-icon class="left-icon" name="home-fill" color="#1776CE" size="50"></u-icon>
			<view class="message-right">
				<h1>泰山安全矿山集团有限公司</h1>
				<view class="message">
					<text>总经理</text>
					<text>TS2022100932520</text>
				</view>
				<p>建档时间: <text>2022-10-09 15:24:00</text></p>
			</view>
		</view>
		<view class="list-warp">
			<view class="list" > 
				<view class="list-box" v-for="(item, index) in list" :key="item.prop">
					<view class="item">
						<view class="item-cell u-line-1">
							<text>建档时间：</text>
							<text>{{item.creatortime}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>名字：</text>
							<text>{{item.username}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>性别：</text>
							<text>{{item.gender.split('')[2] | dynamicText(genderOptions)}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>身份证号：</text>
							<text>{{item.cardid}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>学历：</text>
							<text>{{item.education | dynamicText(educationOptions)}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>健康状况：</text>
							<text>{{item.health.split('')[2]  | dynamicText(healthOptions)}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>籍贯：</text>
							<text>{{item.nativeplace}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>家庭住址：</text>
							<text>{{item.homeaddress}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>入厂时间：</text>
							<text>{{item.jointime}}</text>
						</view>
						<view class="item-cell u-line-1">
							<text>从事工种：</text>
							<text>{{item.typework}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
    import resources from '@/libs/resources.js'
    import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
    import {
        getDictionaryDataSelector,
        getDataInterfaceRes
    } from '@/api/common'
    import request from '@/utils/request'
    export default {
		mixins: [MescrollMixin],
        data() {
            return {
                sortValue: '',
                searchForm: {
                    companyname:undefined,
                    companytitle:undefined,
                    creatortime:undefined,
                    username:undefined,
                    gender:undefined,
                    cardid:undefined,
                    education:undefined,
                    health:undefined,
                    nativeplace:undefined,
                    homeaddress:undefined,
                    jointime:undefined,
                    typework:undefined,
                },
                downOption: {
                    use: true,
                    auto: false
                },
                upOption: {
                    page: {
                        num: 0,
                        size: 20,
                        time: null,
                    },
                    empty: {
                        use: true,
                        icon: resources.message.nodata,
                        tip: "暂无数据",
                        fixed: true,
                        top: "300rpx",
                        zIndex: 5,
                    },
                    textNoMore: '没有更多数据',
                    toTop: {
                        bottom: 250
                    }
                },
                genderOptions:[{"fullName":"男","id":"1"},{"fullName":"女","id":"2"}],
                genderProps:{"label":"fullName","value":"id"},
                educationOptions:[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],
                educationProps:{"label":"fullName","value":"id"},
                healthOptions:[{"fullName":"健康","id":"1"},{"fullName":"不健康","id":"2"}],
                healthProps:{"label":"fullName","value":"id"},
				list: [],
				listQuery: {
				    sort: 'desc',
				    sidx: '',
				    keyword: '',
				    json: ''
				},
				options: [
                    {
                        text: '删除',
                        style: {
                            backgroundColor: '#dd524d'
                        }
                    },
				],
				sortOptions:[
				    {
				        label: '公司名称降序',
				        sidx: 'companyname',
				        value: 'companynamedesc',
				        sort: 'desc'
				    },
				    {
				        label: '公司名称升序',
				        sidx: 'companyname',
				        value: 'companynameasc',
				        sort: 'asc'
				    },
				    {
				        label: '职称降序',
				        sidx: 'companytitle',
				        value: 'companytitledesc',
				        sort: 'desc'
				    },
				    {
				        label: '职称升序',
				        sidx: 'companytitle',
				        value: 'companytitleasc',
				        sort: 'asc'
				    },
				    {
				        label: '建档时间降序',
				        sidx: 'creatortime',
				        value: 'creatortimedesc',
				        sort: 'desc'
				    },
				    {
				        label: '建档时间升序',
				        sidx: 'creatortime',
				        value: 'creatortimeasc',
				        sort: 'asc'
				    },
				    {
				        label: '名字降序',
				        sidx: 'username',
				        value: 'usernamedesc',
				        sort: 'desc'
				    },
				    {
				        label: '名字升序',
				        sidx: 'username',
				        value: 'usernameasc',
				        sort: 'asc'
				    },
				    {
				        label: '性别降序',
				        sidx: 'gender',
				        value: 'genderdesc',
				        sort: 'desc'
				    },
				    {
				        label: '性别升序',
				        sidx: 'gender',
				        value: 'genderasc',
				        sort: 'asc'
				    },
				    {
				        label: '身份证号降序',
				        sidx: 'cardid',
				        value: 'cardiddesc',
				        sort: 'desc'
				    },
				    {
				        label: '身份证号升序',
				        sidx: 'cardid',
				        value: 'cardidasc',
				        sort: 'asc'
				    },
				    {
				        label: '学历降序',
				        sidx: 'education',
				        value: 'educationdesc',
				        sort: 'desc'
				    },
				    {
				        label: '学历升序',
				        sidx: 'education',
				        value: 'educationasc',
				        sort: 'asc'
				    },
				    {
				        label: '健康状况降序',
				        sidx: 'health',
				        value: 'healthdesc',
				        sort: 'desc'
				    },
				    {
				        label: '健康状况升序',
				        sidx: 'health',
				        value: 'healthasc',
				        sort: 'asc'
				    },
				    {
				        label: '籍贯降序',
				        sidx: 'nativeplace',
				        value: 'nativeplacedesc',
				        sort: 'desc'
				    },
				    {
				        label: '籍贯升序',
				        sidx: 'nativeplace',
				        value: 'nativeplaceasc',
				        sort: 'asc'
				    },
				    {
				        label: '家庭住址降序',
				        sidx: 'homeaddress',
				        value: 'homeaddressdesc',
				        sort: 'desc'
				    },
				    {
				        label: '家庭住址升序',
				        sidx: 'homeaddress',
				        value: 'homeaddressasc',
				        sort: 'asc'
				    },
				    {
				        label: '入厂时间降序',
				        sidx: 'jointime',
				        value: 'jointimedesc',
				        sort: 'desc'
				    },
				    {
				        label: '入厂时间升序',
				        sidx: 'jointime',
				        value: 'jointimeasc',
				        sort: 'asc'
				    },
				    {
				        label: '从事工种降序',
				        sidx: 'typework',
				        value: 'typeworkdesc',
				        sort: 'desc'
				    },
				    {
				        label: '从事工种升序',
				        sidx: 'typework',
				        value: 'typeworkasc',
				        sort: 'asc'
				    },
				],
                menuId:'',
            }
        },
		mounted() {
		
		},
        onLoad(e){
			this.menuId = e.menuId
            uni.$on('refresh', () => {
                this.list = [];
                this.mescroll.resetUpScroll();
            })
            this.dataAll()
			this.upCallback()
	
			
        },
        onUnload() {
            uni.$off('refresh')
        },
        methods:{
			dataAll(){
			},
			closeData(e){
			    if(e==1){
			        // this.reset()
			    }
			},
            upCallback(page) {
    //             for(let i in this.searchForm){
				// 	if(!this.searchForm[i]){
				// 		delete this.searchForm[i]
				// 	}
				// }
                const query = {
                    currentPage: this.upOption.num,
                    pageSize: this.upOption.size,
                    menuId : this.menuId,
                    ...this.listQuery,
                    ...this.searchForm
                }
                request({
                    url: '/api/example/Mt_safe_archives/getList',
                    method: 'post',
                    data: query,
                }).then(res => {
					console.log(res.data.list);
				
                    this.list = res.data.list
					console.log(this.list);
                }).catch(() => {
                    
                })
            },
            handleClick(index, index1) {
				const item = this.list[index]
                request({
                    url: '/api/example/Mt_safe_archives/' + item.id,
                    method: 'delete'
                }).then(res => {
                    uni.showToast({
                        title: res.msg,
                        complete: () => {
                            this.$u.toast(res.msg)
                            this.list.splice(index, 1)
							if (!this.list.length) this.mescroll.showEmpty()
                        }
                    })
                })
            },
            open(index) {
                this.list[index].show = true;
                this.list.map((val, idx) => {
                    if (index != idx) this.list[idx].show = false;
                })
            },
            search() {
                if (this.isPreview == '1') return
                this.searchTimer && clearTimeout(this.searchTimer)
                this.searchTimer = setTimeout(() => {
                    this.list = [];
                    this.mescroll.resetUpScroll();
                }, 300)
            },
            goDetail(id, status) {
                let btnType = ''
                let btnList = []
                btnList.push('btn_edit')
                btnList.push('btn_detail')
                if(btnList.includes('btn_detail')){
                    btnType = "btn_detail"
                }
                if(btnList.includes('btn_edit')){
                    btnType = "btn_edit"
                }
                if(!btnType) return
                this.jumPage(id, status,btnType)
            },
            addPage() {
				this.jumPage()
			},
            jumPage(id, status,btnType){
				if (!id && !status) btnType = 'btn_add'
				uni.navigateTo({
                    url: id?'./form?menuId='+this.menuId+'&jurisdictionType='+btnType+'&id=' + id:'./form?menuId='+this.menuId+'&jurisdictionType='+btnType
                })
			},
            cellClick(item) {
                if (this.sortValue === item.value) return
                this.listQuery.sort = item.sort
                this.listQuery.sidx = item.sidx
                this.sortValue = item.value
                this.$refs.uDropdown.close();
                this.$nextTick(() => {
                    this.list = [];
                    this.mescroll.resetUpScroll();
                })
            },
            reset() {
                this.$refs.searchForm.resetFields()
            },
            closeDropdown() {
                this.$refs.uDropdown.close();
                this.$nextTick(() => {
                    this.list = [];
                    this.mescroll.resetUpScroll();
                })
            },
			dataList(data){
				let _list =[]
				for(let i=0;i<data.list.length;i++){
					let _data = data.list[i]
                    _data.gender = JSON.parse(_data.gender)
                    _data.health = JSON.parse(_data.health)
					_list.push(_data)
				}
				return _list;
			},
        },
    }
</script>
<style lang="scss">
	page {
		background-color: #f0f2f6;
		height: 100%;
		/* #ifdef MP-ALIPAY */
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		/* #endif */
		.company-message{
			width: calc(100% - 40rpx);
			margin: 20rpx auto 0rpx auto;
			background-color: #fff;
			border-radius: 18rpx;
			padding: 30rpx 30rpx;
			display: flex;
			align-items: flex-start;
			.left-icon{
				flex-shrink: 0;
				margin-right: 28rpx;
			}
			.message-right{
				h1{
					font-size:34rpx;
					font-weight: bold;
					color: #333333;
				}
				.message{
					font-size: 30rpx;
					color: #333333;
					display: flex;
					align-items: center;
					text{
						margin:18rpx 0 18rpx 0;
						&:last-child{
							margin-left: 20rpx;
						}
					}
				}
				p{
					font-size: 26rpx;
					font-weight: 400;
					color: #797F85;
				}
			}
		}
		.list-warp {
			.list {
				.list-box {
					border-radius: 16rpx;
					overflow: hidden;
					.item {
						.item-cell {
							display: flex;
							justify-content: space-between;
							align-items: center;
							border-bottom: 1px solid #F9F9F9;
		
							text {
								font-size: 30rpx;
		
								&:first-child {
									color: #333;
								}
		
								&:last-child {
									color: #797F85;
								}
							}
						}
					}
				}
				.people-histroy {
					width: 100%;
					margin: 0rpx auto 20rpx auto;
					background-color: #fff;
					border-radius: 18rpx;
					padding: 20rpx 30rpx  10rpx 30rpx;
					.accident,.illegal{
						.ac-item{
							background-color: #F8F8F8;
							border-radius: 16rpx;
							padding: 28rpx;
							margin-bottom: 20rpx;
							p{
								line-height: 1.5;
								text-align: justify;
								&.time{
									color: #a5a5a5;
									margin-top: 10rpx;
								}
							}
						}
					}
				}
			}
		}
	}
</style>
